<?php
/**
 * Created by PhpStorm.
 * User: geolo
 * Date: 2018/12/12
 * Time: 16:16
 */
namespace app\modules\mch\models;
use app\models\Goods;
use app\models\ContentGood;
use app\models\Store;
use yii\data\Pagination;
/**
 * @property ContentGood $model
 * @property Store $store
 */
class ContentGoodForm extends Model
{
    public $model;
    public $store_id;
    public $content_id;
    public $goods_id;
    public $pagesize;
    public $pages;
    public $is_delete;


    public function rules()
    {
        return [
            [['store_id', 'pagesize','pages','goods_id','content_id'], 'integer'],
            [['store_id','goods_id','content_id'],'required']
        ];
    }
    public function attributeLabels()
    {
        return [
            'store_id' => 'Store ID',
            'goods_id' => '选择商品',
            'content_id'=>'内容id',
        ];
    }

    public function save()
    {
        if (!$this->validate()) {
            return $this->getModelError();
        }
        $this->model->store_id = $this->store_id;
        $goods_id = $this->goods_id;
        $content_id = $this->content_id;
        $this->model->goods_id = $goods_id;
        $this->model->content_id = $content_id;
        $this->model->is_delete = $this->is_delete;
        if ($this->model->save())
            return [
                'code' => 0,
                'msg' => '保存成功',
            ];
        else
            return $this->getModelError($this->model);
    }

}